#include<bits/stdc++.h>
using namespace std;
int n,l,r,a,b;
int main()
{
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	cin>>n>>l>>r;
	b=r%n;
	if (r-b>l)
		cout<<n-1;
	else cout<<b;
	return 0;
 } 
